package org.zkzd.helloEasyQuery.entity;

import com.easy.query.core.annotation.*;
import com.easy.query.core.enums.RelationTypeEnum;
import com.easy.query.core.proxy.ProxyEntityAvailable;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import org.zkzd.helloEasyQuery.entity.proxy.CompanyProxy;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Data
@Table("t_company")
@EntityProxy
@FieldNameConstants
@EasyAlias("company")
@EasyAssertMessage("未找到公司信息")
public class Company implements ProxyEntityAvailable<Company , CompanyProxy> {
    /**
     * 企业id
     */
    @Column(primaryKey = true, generatedKey = true, comment = "企业id")
    private Long id;
    /**
     * 企业名称
     */
    @Column(comment = "企业名称")
    private String name;

    /**
     * 企业创建时间
     */
    @Column(comment = "企业创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    /**
     * 注册资金
     */
    @Column(comment = "注册资金")
    private BigDecimal registerMoney;

    /**
     * 企业拥有的用户
     */
    @Navigate(value = RelationTypeEnum.OneToMany,
            selfProperty = {Company.Fields.id},
            targetProperty = {SysUser.Fields.companyId})
    private List<SysUser> users;
}